import React, { Component } from 'react'
import Snackbar from 'material-ui/Snackbar';

class MessageBar extends Component {
	constructor(props) {
	  super(props);
	}

	handleRequestClose = () => {
		this.props.handleMessage({
			visiable: false,
			content: ''
		})
  };

	render() {
		const { message } = this.props
		return (
      <Snackbar
			  anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
			  open={message.visiable}
			  onRequestClose={() => this.handleRequestClose()}
			  SnackbarContentProps={{
			    'aria-describedby': 'message-id',
			  }}
			  message={<span id="message-id">{message.content}</span>}
			  autoHideDuration={2000}
			/>
		)
	}
}

export default MessageBar